package com.zwt.controller;

import com.alibaba.fastjson.JSON;
import com.zwt.constant.UrlConstant;
import com.zwt.model.TAccountUser;
import com.zwt.service.ApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by zwt on 2018/9/6.
 */
@Controller
@RequestMapping("app")
public class TAccountUserController {


    @Autowired
    private UrlConstant urlConstant;

    @Autowired
    private ApiService apiService;


    /**
     * 使用 zuul调用服务
     * @param id
     * @return
     */
    @RequestMapping("queryById")
    @ResponseBody
    public TAccountUser queryById(@RequestParam Long id){
        String requestUrl = urlConstant.getQueryById();
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("id",id);
        String json = apiService.getJson(requestUrl, map,urlConstant.getHost());
        TAccountUser tAccountUser = JSON.parseObject(json, TAccountUser.class);
        return tAccountUser;
    }


}
